#include "kcustomdialog.h"

KCustomDialog::KCustomDialog(QWidget *parent)
    : QDialog(parent)
{
    ui.setupUi(this);
    init();
}

void KCustomDialog::init()
{
	QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");
	ui.lineEdit->setValidator(new QRegExpValidator(regExp, this));
	ui.btnOk->setEnabled(false);

	(void)connect(ui.btnOk, &QPushButton::clicked, this, &KCustomDialog::accept);
	(void)connect(ui.btnCancel, &QPushButton::clicked, this, &KCustomDialog::rejected);
	(void)connect(ui.lineEdit, &QLineEdit::textChanged, this,&KCustomDialog::onLineEditTextChanged);

}

void KCustomDialog::onLineEditTextChanged()
{
	qDebug() << "running";
	ui.btnOk->setEnabled(ui.lineEdit->hasAcceptableInput());
}


KCustomDialog::~KCustomDialog()
{}
